<template>
  <div class="kpi-devired-index">
    <div class="section-title"><icon-svg name="iconCommon"></icon-svg>衍生指标配置信息</div>
    <div class="section-content">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="source-item">
            <div class="star"></div>
            <div class="source-title linear-purpose">原子指标</div>
            <div class="source-content">
              {{ tag.jsonConfig.atomicNm }}
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="source-item">
            <div class="source-title linear-purpose">维度</div>
            <div class="source-content">
              {{ tag.jsonConfig.dimensionNm || '暂无' }}
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="source-item">
            <div class="source-title linear-purpose">时间修饰词</div>
            <div class="source-content">
              {{ tag.jsonConfig.timeModifiersNm || '暂无' }}
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="source-item">
            <div class="source-title linear-purpose">时间映射字段</div>
            <div class="source-content">
              {{ tag.jsonConfig.timeColumn || '暂无' }}
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="source-item">
            <div class="source-title linear-cyan">业务修饰词</div>
            <div class="source-content">
              {{
                tag.jsonConfig.businessModifiersId || tag.jsonConfig.businessModifiersJson.length
                  ? tag.jsonConfig.businessModifiersName
                  : '暂无'
              }}
            </div>
          </div>
        </el-col>
      </el-row>
      <devired-logic v-if="tag.jsonConfig.businessModifiersJson.length" :tagConfig="tagConfig"></devired-logic>
    </div>
    <kpi-relation :tagType="tag.tagType" :tagId="tag.tagId"></kpi-relation>
    <devired-result :tag="tag.jsonConfig ? tag.jsonConfig : {}"></devired-result>
  </div>
</template>

<script>
import deviredResult from './devired-index-result'
import deviredLogic from './devired-logic'
import kpiRelation from '../components/kpi-relation'
import bussunessConfig from '../bussiness/bussiness-config.js'
export default {
  components: {
    deviredResult,
    kpiRelation,
    deviredLogic
  },
  props: {
    tag: {
      type: Object,
      required: true,
      default: () => {}
    }
  },
  computed: {
    tagConfig() {
      // if (this.tag.jsonConfig.businessModifiersId) return {}
      let config = {
        logicalOperation: 'and',
        tagList: []
      }
      let logicJson = this.tag.jsonConfig.businessModifiersJson
        ? JSON.parse(this.tag.jsonConfig.businessModifiersJson).tagConfig
        : {}
      config.logicalOperation = logicJson.request.labGrps.logicTyp
      config.tagList = bussunessConfig.initLogic(logicJson.request.labGrps.labs)
      return config
    }
  },
  data() {
    return {}
  },
  methods: {}
}
</script>

<style lang="scss">
.kpi-devired-index {
  .section-title {
    font-size: 17px;
    font-weight: bold;
    padding: 0 10px;
    height: 50px;
    line-height: 50px;
    color: #fff;
    background-color: #5391ef;
    border-radius: 2px;
    svg {
      width: 25px;
      height: 25px;
      vertical-align: middle;
      margin: -3px 5px 0 0;
    }
  }
  .section-content {
    width: 100%;
    padding: 20px;
    border: 1px solid #ccc;
    overflow: hidden;
  }
  .source-item {
    width: 100%;
    height: 45px;
    margin-bottom: 20px;
    box-shadow: #eee 0 0 10px;
    position: relative;
    .source-title {
      font-weight: bold;
      width: 150px;
      padding-left: 50px;
      line-height: 45px;
      color: #fff;
      position: absolute;
      &:before {
        width: 10px;
        height: 10px;
        content: '';
        background-color: #eee9ff;
        border: 2px solid #cfc7ee;
        margin-top: -5px;
        position: absolute;
        top: 50%;
        left: 20px;
        border-radius: 50%;
      }
      &:after {
        width: 0;
        height: 0;
        content: '';
        margin-top: -10px;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        position: absolute;
        top: 50%;
        right: -10px;
      }
      &.linear-purpose:after {
        border-left: 10px solid #7c6bed;
      }
      &.linear-blue:after {
        border-left: 10px solid #635fd7;
      }
      &.linear-cyan:after {
        border-left: 10px solid #0696ec;
      }
      &.linear-red:after {
        border-left: 10px solid #c563ee;
      }
    }
    .source-content {
      line-height: 45px;
      padding: 0 30px 0 180px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      &.rela-content {
        padding-left: 195px;
      }
    }
    .el-select {
      width: 100%;
    }
    .el-select .el-input__inner,
    .el-input .el-input__inner {
      height: 45px;
      line-height: 45px;
      border: 0;
      background-color: transparent;
    }
  }
}
</style>
